/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
"""Just testing the IOClient Python wrapper"""

import sys, time
sys.path.append("../../../GIMI")
sys.path.append("../../../interfaces/wrap/Python/lib")
import IOClient 
import gimi
g= gimi.GIMI()
ioc = IOClient.CIOClient(g, 0)
#r = g.connectToHubEx("asrobo.hut.fi", 50002, "iocTest")
r = g.connectToHubEx("130.233.120.103", 50005, "iocTest")
r = ioc.SetDefaultTarget(IOClient.SMaCISL("Rolloottori.MaCI_IO.io"))
if !r:
	r = ioc.SetDefaultTarget(IOClient.SMaCISL("Rolloottori.MaCI_IO.io"))
if r:
	r = ioc.Open()
	print "Open:", r
	print "AI 0", ioc.GetAnalogVoltage(0, 1000)
	print "AI 1", ioc.GetAnalogVoltage(1, 1000)
	print "AI 2", ioc.GetAnalogVoltage(2, 1000)
	print "AI 3", ioc.GetAnalogVoltage(3, 1000)
	print "DI 0", ioc.GetDigitalPin(0, 1000)
	print "DI 1", ioc.GetDigitalPin(1, 1000)
	print "DI 2", ioc.GetDigitalPin(2, 1000)
	print "DI 3", ioc.GetDigitalPin(3, 1000)
	print "DI 4", ioc.GetDigitalPin(4, 1000)
	print "DI 5", ioc.GetDigitalPin(5, 1000)
	print "DI 6", ioc.GetDigitalPin(6, 1000)
	#ioc.SetDigitalPin(0,1)
	time.sleep(1.0)
	#ioc.SetDigitalPin(0,0)
	ioc.Close()
else: 
	print "Could not set the target"
g.stop()



